package cn.zdm.demo.config.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * copyright (C), 2021, 武大吉奥科技有限公司
 *
 * @Program demo
 * @Description
 * swagger 配置类
 * @Author ZhaoDeman
 * @Create 2021/3/1 20:32
 * @Version 1.0.0
 * <author>                <time>                  <version>                   <description>
 * ZhaoDeman        2021/3/1 20:32                 1.0
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
     * 设置groupName 可以进行多个controller 包扫描
     * @return
     */
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .groupName("test")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zdm.demo.test.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    @Bean
    public ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("Restful 接口测试")
                .description("接口信息描述")
                .version("1.0.0")
                .contact(new Contact("测试", null, "zhaodeman8888@163.com"))
                .build();
    }
}
